import { findHeadCategory } from '@/api/home'

export default {
  namespaced: true,
  state () {
    return {
      // 分类导航列表数据
      navList: []
    }
  },
  mutations: {
    // 存储分类数据
    updateNav (state, payload) {
      state.navList = payload
    }
  },
  actions: {
    // 从后台获取分类数据
    async getNavList ({ commit }) {
      const { result } = await findHeadCategory()
      console.log('分类数据：', result)
      commit('updateNav', result)
    }
  }
}
